﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:StressServer.ViewModel"
        xmlns:local="clr-namespace:StressServer_UI" x:Class="StressServer_UI.MainWindow"
        x:Name="Root"
        Title="StressTester" Height="640" Width="623.2" ResizeMode="NoResize">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
        
        <Style x:Key="CaptionBig" TargetType="{x:Type Label}">
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="FontSize" Value="14"/>
        </Style>
        <Style x:Key="Caption" TargetType="{x:Type Label}">
            <Setter Property="FontWeight" Value="Normal"/>
            <Setter Property="Padding" Value="0"/>
        </Style>
        <Style x:Key="ClientName" TargetType="{x:Type TextBlock}">
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Foreground" Value="#000000"/>
            <Setter Property="Margin" Value="5,5,5,5"/>
        </Style>
        <Style x:Key="ClientBG" TargetType="{x:Type Grid}">
            <Setter Property="Background" Value="#FFFFFF"/>
        </Style>
        <Style x:Key="ClientNameBG" TargetType="{x:Type Grid}">
            <Setter Property="Background" Value="#FFFFFF"/>
        </Style>
        <Style x:Key="ClientBorder" TargetType="{x:Type Border}">
            <Setter Property="BorderBrush" Value="#7C9963"/>
            <Setter Property="BorderThickness" Value="2"/>
            <Setter Property="Margin" Value="5,5,5,10"/>
        </Style>
    </Window.Resources>
    <Grid>
        <TabControl HorizontalAlignment="Left" Height="600" Margin="0,10,0,-36.4" VerticalAlignment="Top" Width="610" >
            <TabItem  Width="100" Height="30" VerticalAlignment="Bottom" BorderThickness="1">
                <TabItem.Header>
                    <TextBlock>
                    <TextBlock.ToolTip>
                    <ToolTip>
                        <StackPanel>
                            <TextBlock FontWeight="Bold">Server</TextBlock>
                            <TextBlock>Manage connected clients and server.</TextBlock>
                        </StackPanel>
                    </ToolTip>
                    </TextBlock.ToolTip>
                        Server
                    </TextBlock>
                </TabItem.Header>
                <Grid Background="#FFFFFF" Margin="0,0,-13.6,-0.4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="53*"/>
                        <ColumnDefinition Width="97*"/>
                        <ColumnDefinition Width="463*"/>
                    </Grid.ColumnDefinitions>
                    <Button  x:Name="ButtonGoOnline" Command="{Binding CommandConnect}" Visibility="{Binding IsDisconnected, Converter={StaticResource booleanToVisibilityConverter}}" Content="Go online" HorizontalAlignment="Left" Margin="10,25,0,0" VerticalAlignment="Top" Width="75" Grid.ColumnSpan="2">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Go online</TextBlock>
                                    <TextBlock>Make the server available to clients at the specified port.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>
                    </Button>
                    <Button  x:Name="ButtonGoOffline" Command="{Binding CommandDisconnect}" Visibility="{Binding IsConnected, Converter={StaticResource booleanToVisibilityConverter}}" Content="Go offline" HorizontalAlignment="Left" Margin="10,25,0,0" VerticalAlignment="Top" Width="75" Grid.ColumnSpan="2">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Go offline</TextBlock>
                                    <TextBlock>Disconnect all clients and go offline.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>                    
                    </Button>
                    <TextBox x:Name="TextPort" HorizontalAlignment="Left" Height="23" Margin="56.2,26,0,0" TextWrapping="Wrap" Text="{Binding Port}" IsEnabled="{Binding IsDisconnected}" VerticalAlignment="Top" Width="48" Grid.Column="1" Grid.ColumnSpan="2">
                        <TextBox.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Port</TextBlock>
                                    <TextBlock>The port the server will listen to for incoming client connections.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </TextBox.ToolTip>
                    </TextBox>
                    <TextBlock HorizontalAlignment="Left" Margin="56.2,10,0,0" TextWrapping="Wrap" Text="Port" VerticalAlignment="Top" Grid.Column="1"/>
                    <TextBlock Text="Connected clients:" HorizontalAlignment="Left" Margin="11,170,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
                    <ListBox HorizontalAlignment="Left" Height="286" Margin="10,195,0,0" VerticalAlignment="Top" Width="456" ItemsSource="{Binding Clients}" BorderBrush="#E2DFDE" Background="#FFE5E5E5"
                         Grid.IsSharedSizeScope="True"
                        HorizontalContentAlignment="Stretch" Grid.ColumnSpan="3">
                        <ListBox.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Connected clients</TextBlock>
                                    <TextBlock>Clients connected to the server will show up here.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </ListBox.ToolTip>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Border BorderBrush="Black" BorderThickness="1" Margin="5,5,5,5">
                                    <StackPanel Orientation="Vertical" Background="White">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Style="{StaticResource ClientName}" Text="{Binding IP}" Width="120">
                                                <TextBlock.ToolTip>
                                                    <ToolTip>
                                                        <StackPanel>
                                                            <TextBlock FontWeight="Bold">Connected clients</TextBlock>
                                                            <TextBlock>Clients connected to the server will show up here.</TextBlock>
                                                        </StackPanel>
                                                    </ToolTip>
                                                </TextBlock.ToolTip>                                                
                                            </TextBlock>
                                            <TextBlock Style="{StaticResource ClientName}" Text="{Binding UserAndDomainName}" Width="200">
                                                <TextBlock.ToolTip>
                                                    <ToolTip>
                                                        <StackPanel>
                                                            <TextBlock FontWeight="Bold">Domain / User</TextBlock>
                                                            <TextBlock>Domain and user of connected client.</TextBlock>
                                                        </StackPanel>
                                                    </ToolTip>
                                                </TextBlock.ToolTip>
                                            </TextBlock>
                                            <Button Command="{Binding CommandDisconnectClient}" Content="Disconnect" HorizontalAlignment="Right" Margin="5,5,5,5">
                                                <Button.ToolTip>
                                                    <ToolTip>
                                                        <StackPanel>
                                                            <TextBlock FontWeight="Bold">Disconnect client</TextBlock>
                                                            <TextBlock>Force client to disconnect from server.</TextBlock>
                                                        </StackPanel>
                                                    </ToolTip>
                                                </Button.ToolTip>
                                            </Button>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock VerticalAlignment="Top" Width="200" FontSize="16" Margin="5,0,0,0" Text="{Binding Status}"></TextBlock>
                                            <StackPanel Orientation="Vertical" Margin="0,0,0,5">
                                                <TextBlock Text="Test progress"/>
                                                <ProgressBar Width="200" Height="20" Value="{Binding QueriesCompleted}" Maximum="{Binding TotalQueryCount}" Minimum="0"></ProgressBar>
                                            </StackPanel>
                                        </StackPanel>
                                    </StackPanel>
                                </Border>
                            </DataTemplate>
                        </ListBox.ItemTemplate>                        
                    </ListBox>
                    <Button Command="{Binding CommandExecuteTest}" IsEnabled="{Binding IsTestExecutable}" Content="Execute test" HorizontalAlignment="Left" Margin="334.8,54,0,0" VerticalAlignment="Top" Width="81" Height="30" RenderTransformOrigin="0.556,-1.267" Grid.Column="2">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Execute test</TextBlock>
                                    <TextBlock>Execute test.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>
                    </Button>
                    <Button Command="{Binding CommandAbortTest}" IsEnabled="{Binding IsTestExecuting}" Content="Abort test" HorizontalAlignment="Left" Margin="334.8,89,0,0" VerticalAlignment="Top" Width="81" Height="30" RenderTransformOrigin="0.556,-1.267" Grid.Column="2">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Abort test</TextBlock>
                                    <TextBlock>Abort currently executing test. This may take some time as clients will need to complete the query they are currently executing.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>
                    </Button>
                    <TextBox HorizontalAlignment="Left" Height="23" Margin="9.8,163,0,0" TextWrapping="Wrap" Text="{Binding Message}" VerticalAlignment="Top" Width="200" Grid.Column="2">
                        <TextBox.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Message</TextBlock>
                                    <TextBlock>Message text to send to all clients.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </TextBox.ToolTip>
                    </TextBox>
                    <Button Command="{Binding CommandSendMessage}" Content="Send message" Grid.Column="2" HorizontalAlignment="Left" Margin="219.8,163,0,0" VerticalAlignment="Top" Width="96">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock FontWeight="Bold">Send message</TextBlock>
                                    <TextBlock>Send text message to all clients.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>
                    </Button>
                    <TextBlock HorizontalAlignment="Left" Margin="59.2,170,0,0" TextWrapping="Wrap" Text="{Binding Clients.Count}" FontWeight="Bold" TextAlignment="Left" VerticalAlignment="Top" Width="43" Grid.Column="1" Grid.ColumnSpan="2"/>
                    <Canvas HorizontalAlignment="Left" Height="60" Margin="11,484,0,0" VerticalAlignment="Top" Width="455" Grid.ColumnSpan="3" >
                        <ProgressBar  HorizontalAlignment="Left" Height="28"  VerticalAlignment="Top" Width="445" Canvas.Left="10" Canvas.Top="22" Maximum="{Binding TotalNumberOfQueries}" Value="{Binding QueriesCompleted}"/>
                        <TextBlock Grid.ColumnSpan="2" HorizontalAlignment="Left"  TextWrapping="Wrap" Text="{Binding TestDuration}" VerticalAlignment="Top" Width="49" Canvas.Left="91" Canvas.Top="5"/>
                        <Label Content="Running time" Canvas.Left="10"/>
                        <Label Content="Queries" Canvas.Left="323"/>
                        <StackPanel Height="16" Canvas.Left="366" Orientation="Horizontal" Canvas.Top="5">
                            <TextBlock TextAlignment="Right"  TextWrapping="Wrap" Text="{Binding QueriesCompleted}" VerticalAlignment="Top" Width="39"/>
                            <TextBlock TextAlignment="Right"  TextWrapping="Wrap" Text="/" VerticalAlignment="Top" Width="8"/>
                            <TextBlock TextAlignment="Right"  TextWrapping="Wrap" Text="{Binding TotalNumberOfQueries}" VerticalAlignment="Top" Width="40"/>
                        </StackPanel>
                        
                        <Label Content="Errors" Canvas.Left="204"/>
                        <TextBlock HorizontalAlignment="Left"  TextWrapping="Wrap" Text="{Binding QueryErrors}" VerticalAlignment="Top" Width="49" Canvas.Left="255" Canvas.Top="5"/>                      
                    </Canvas>
                    <TextBlock Grid.Column="2" HorizontalAlignment="Left" Margin="22.8,17,0,0" TextWrapping="Wrap" Text="{Binding Status}" VerticalAlignment="Top" FontSize="24" Width="365"/>
                    <ListBox Grid.ColumnSpan="3" HorizontalAlignment="Left" Height="100" Margin="11,54,0,0" VerticalAlignment="Top" Width="455" ItemsSource="{Binding Messages}"  IsManipulationEnabled="False">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock x:Name="Message" Text="{Binding FormattedMessage}" TextWrapping="Wrap" Width="430">
                                </TextBlock>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Type}" Value="1">
                                        <Setter TargetName="Message" Property="Foreground" Value="Black"></Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Type}" Value="2">
                                        <Setter TargetName="Message" Property="Foreground" Value="Green"></Setter>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Type}" Value="3">
                                        <Setter TargetName="Message" Property="Foreground" Value="Red"></Setter>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </TabItem>
            <TabItem Width="100" Height="30">
                <TabItem.Header>
                    <TextBlock>
                    <TextBlock.ToolTip>
                    <ToolTip>
                        <StackPanel>
                            <TextBlock FontWeight="Bold">Test</TextBlock>
                            <TextBlock>Manage test</TextBlock>
                        </StackPanel>
                    </ToolTip>
                   </TextBlock.ToolTip>
                        Test
                    </TextBlock>
                </TabItem.Header>

                <Grid Background="#FFFFFF">
                    <TabControl  TabStripPlacement="Right" HorizontalAlignment="Left" Height="400" Margin="11,62,0,0" VerticalAlignment="Top" Width="555" Visibility="{Binding HasTest, Converter={StaticResource booleanToVisibilityConverter}}">
                        <TabItem  Height="50" Width="75"  VerticalAlignment="Top">
                            <TabItem.Header>

                                <TextBlock>
                                <TextBlock.ToolTip>
                                    <ToolTip>
                                        <StackPanel>
                                            <TextBlock FontWeight="Bold">General</TextBlock>
                                            <TextBlock>General test configuration.</TextBlock>
                                        </StackPanel>
                                    </ToolTip>
                                </TextBlock.ToolTip>
                                    General
                                </TextBlock> 
                            </TabItem.Header>

                            <Grid Background="#FFE5E5E5">
                                <TextBox x:Name="TextTestName" HorizontalAlignment="Left" Height="23" Margin="18,41,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="273">
                                    <TextBox.Text>                                       
                                    <Binding Path="Test.Name" Mode="TwoWay">
                                    </Binding>
                                    </TextBox.Text>
                                    <TextBox.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Test name</TextBlock>
                                                <TextBlock>Name of test to identify it in the output.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </TextBox.ToolTip>
                                </TextBox>
                                <TextBox x:Name="TextOutputPath" HorizontalAlignment="Left" Height="23" Margin="18,90,0,0" TextWrapping="NoWrap" Text="{Binding Path=Test.OutputPath, Mode=TwoWay}" VerticalAlignment="Top" Width="273">
                                    <TextBox.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Output path</TextBlock>
                                                <TextBlock>Path to file where stresstester will log its results.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </TextBox.ToolTip>
                                </TextBox>
                                <Button x:Name="BtnSelOutputFile" Command="{Binding Test.CommandSetOutput}" Content="Select output file" HorizontalAlignment="Left" Margin="296,91,0,0" VerticalAlignment="Top" Width="100">
                                    <Button.ToolTip>
                                        <ToolTip>
                                            <StackPanel>                                               
                                                <TextBlock>Select output file</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </Button.ToolTip>
                                </Button>
                                <CheckBox x:Name="CheckOverwriteOutput" Content="Append to file" HorizontalAlignment="Left" Margin="22,118,0,0" VerticalAlignment="Top" IsChecked="{Binding Test.Append, Mode=TwoWay}">
                                    <CheckBox.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Append to file</TextBlock>
                                                <TextBlock>Check this to append test output to file. Leave it unchecked to overwrite file.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </CheckBox.ToolTip>
                                </CheckBox>
                                <Label Content="Test output" Style="{StaticResource CaptionBig}" HorizontalAlignment="Left" Margin="18,72,0,0" VerticalAlignment="Top" />
                                <Label Content="Test name" Style="{StaticResource CaptionBig}" HorizontalAlignment="Left" Margin="20,23,0,0" VerticalAlignment="Top"/>
                                <Label Content="Test target" Style="{StaticResource CaptionBig}" HorizontalAlignment="Left" Margin="22,143,0,0" VerticalAlignment="Top"/>
                                <TextBox x:Name="TextTargetServer" HorizontalAlignment="Left" Height="23" Margin="20,178,0,0" TextWrapping="NoWrap" Text="{Binding Test.ServerName, Mode=TwoWay}" VerticalAlignment="Top" Width="149">
                                    <TextBox.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Target server</TextBlock>
                                                <TextBlock>The server to run test queries against.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </TextBox.ToolTip>
                                </TextBox>
                                <Label Content="Server" Style="{StaticResource Caption}" HorizontalAlignment="Left" Margin="22,162,0,0" VerticalAlignment="Top"/>
                                <TextBox x:Name="TestTargetDatabase" HorizontalAlignment="Left" Height="23" Margin="192,178,0,0" TextWrapping="NoWrap" Text="{Binding Test.DatabaseName, Mode=TwoWay}" VerticalAlignment="Top" Width="149">
                                    <TextBox.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Target database</TextBlock>
                                                <TextBlock>The database to run test queries against.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </TextBox.ToolTip>
                                </TextBox>
                                <Label Content="Database" Style="{StaticResource Caption}" HorizontalAlignment="Left" Margin="192,162,0,0" VerticalAlignment="Top"/>
                                <Label Content="Test Configuration" Style="{StaticResource CaptionBig}" HorizontalAlignment="Left" Margin="24,208,0,0" VerticalAlignment="Top"/>
                                <RadioButton Content="Run queries sequentially" GroupName="QueryPick" HorizontalAlignment="Left" Margin="219,231,0,0" VerticalAlignment="Top" IsChecked="{Binding Test.IsRandom, Mode=TwoWay}">
                                    <RadioButton.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Run queries sequentially</TextBlock>
                                                <TextBlock>Run queries in the order they are listed under the "Queries" tab.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </RadioButton.ToolTip>
                                </RadioButton>
                                <RadioButton Content="Run queries in random order" GroupName="QueryPick" HorizontalAlignment="Left" Margin="22,231,0,0" VerticalAlignment="Top" IsChecked="{Binding Test.IsSequential, Mode=TwoWay}">
                                    <RadioButton.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Run queries in random order</TextBlock>
                                                <TextBlock>Randomize the execution order of queries. The list of queries will be randomized per client.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </RadioButton.ToolTip>
                                </RadioButton>
                                <StackPanel Margin="69,255,226.8,112.4" Orientation="Horizontal">
                                    <StackPanel.ToolTip>
                                        <ToolTip Width="400">
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold"><Run Text="Times to repeat test"/></TextBlock>
                                                <TextBlock><Run Text="Number of test iterations. Randomized queries will be executed in the same order per execution."/></TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </StackPanel.ToolTip>
                                    <Label Content="Times to repeat test" Style="{StaticResource Caption}" HorizontalAlignment="Left" Margin="0,7,0,0" VerticalAlignment="Top" Width="108"/>
                                    <TextBox HorizontalAlignment="Left"  Height="23" TextWrapping="Wrap" Text="{Binding Test.Repeat}" VerticalAlignment="Top" Width="60">
                                    </TextBox>
                                </StackPanel>
                                <CheckBox Content="Clear SSAS cache before running test" HorizontalAlignment="Left" Margin="27,361,0,0" VerticalAlignment="Top" IsChecked="{Binding Test.DoClearCache}">
                                    <CheckBox.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Clear cache</TextBlock>
                                                <TextBlock>Clear the cache in Analysis Services prior to executing the test.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </CheckBox.ToolTip>
                                </CheckBox>
                                <StackPanel Margin="32,311,231.8,56.4" Orientation="Horizontal">
                                    <StackPanel.ToolTip>
                                        <ToolTip Width="400">
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold"><Run Text="Number of threads"/></TextBlock>
                                                <TextBlock TextWrapping="Wrap"><Run Text="Number of threads to run per client. Each thread will run the test in full."/></TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </StackPanel.ToolTip>
                                    <Label Content="Number of threads" HorizontalContentAlignment="Right" Style="{StaticResource Caption}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="140" Margin="0,7,0,0"/>
                                    <TextBox HorizontalAlignment="Left"  Height="23" TextWrapping="Wrap" Text="{Binding Test.TestThreadCount}" VerticalAlignment="Top" Width="60" Margin="6,0,0,0">

                                    </TextBox>
                                </StackPanel>
                                <StackPanel Margin="27,283,146.8,84.4" Orientation="Horizontal">
                                    <StackPanel.ToolTip>
                                        <ToolTip Width="400">
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold"><Run Text="Delay between queries"/></TextBlock>
                                                <TextBlock TextWrapping="Wrap"><Run Text="Delay in milliseconds the clients pause between issuing queries against the server. The pause will be a random number of milliseconds between from and to."/></TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </StackPanel.ToolTip>
                                    <Label Content="Delay between queries (ms)" Style="{StaticResource Caption}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="150" Margin="0,7,0,0"/>
                                    <TextBox HorizontalAlignment="Left" x:Name="TextRepeat" Height="23" TextWrapping="Wrap" Text="{Binding Test.DelayFrom}" VerticalAlignment="Top" Width="60">
                                    </TextBox>
                                    <Label Content="to" Style="{StaticResource Caption}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="12" Margin="0,7,0,0"/>
                                    <TextBox HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="{Binding Test.DelayTo}" VerticalAlignment="Top" Width="60">
                                    </TextBox>
                                </StackPanel>
                            </Grid>
                        </TabItem>
                        <TabItem  Height="50">
                            <TabItem.Header>
                                <TextBlock>
                                    <TextBlock.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Queries</TextBlock>
                                                <TextBlock>Queries to execute.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </TextBlock.ToolTip> 
                                    Queries
                                </TextBlock>
                            </TabItem.Header>
                            <Grid Background="#FFE5E5E5">
                                <ListBox x:Name="ListQueries" DisplayMemberPath="Name" SelectedItem="{Binding Test.CurrentQuery}" ItemsSource="{Binding Test.Queries}" HorizontalAlignment="Left" Height="260" Margin="10,40,0,0" VerticalAlignment="Top" Width="191">
                                    <ListBox.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Queries</TextBlock>
                                                <TextBlock>Queries to execute.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </ListBox.ToolTip>                                
                                </ListBox>
                                <local:QueryControl HorizontalAlignment="Left" Margin="206,30,0,0" VerticalAlignment="Top" Visibility="{Binding Path=Test.HasCurrentQuery, Converter={StaticResource booleanToVisibilityConverter} }"/>
                                <Button Content="Del" Command="{Binding Test.CommandRemoveCurrentQuery}" Name="BtnQueryDelete" HorizontalAlignment="Left" Margin="114,10,0,0" VerticalAlignment="Top" Width="41">
                                    <Button.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock>Delete query.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </Button.ToolTip>
                                </Button>
                                <Button Content="Up" Command="{Binding Test.CommandMoveUpCurrentQuery}" Name="BtnQueryUp" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="41">
                                    <Button.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock>Move query up.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </Button.ToolTip>
                                </Button>
                                <Button Content="Down" Command="{Binding Test.CommandMoveDownCurrentQuery}" x:Name="BtnQueryDown" HorizontalAlignment="Left" Margin="56,10,0,0" VerticalAlignment="Top" Width="41">
                                    <Button.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock>Move query down.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </Button.ToolTip>
                                </Button>
                                <Button Content="New" Command="{Binding Test.CommandAddQuery}" x:Name="BtnQueryAdd" HorizontalAlignment="Left" Margin="160,10,0,0" VerticalAlignment="Top" Width="41">
                                    <Button.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock>Add new query.</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </Button.ToolTip>
                                </Button>
                                <Button Command="{Binding Test.CommandShowTraceFile}" Content="Import queries from trace file" HorizontalAlignment="Left" Margin="267,10,0,0" VerticalAlignment="Top" Width="178">
                                    <Button.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock>Configure SQL Server trace file import</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </Button.ToolTip>
                                </Button>
                            </Grid>
                        </TabItem>
                    </TabControl>
                    <Button x:Name="BtnLoadTest" Command="{Binding Path=CommandLoadTest}" Content="Load test" HorizontalAlignment="Left" Margin="101,22,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.069,0.074">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock>Load a saved test.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>
                    </Button>
                    <Button x:Name="BtnSaveTest" Command="{Binding Path=CommandSaveTest}" Content="Save test" HorizontalAlignment="Left" Margin="189,22,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="1.6,0.824">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock>Save test.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>
                    </Button>
                    <Button x:Name="btnNewTest" Command="{Binding CommandNewTest}" Content="New test" HorizontalAlignment="Left" Margin="11,22,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.069,0.074">
                        <Button.ToolTip>
                            <ToolTip>
                                <StackPanel>
                                    <TextBlock>Create new test.</TextBlock>
                                </StackPanel>
                            </ToolTip>
                        </Button.ToolTip>
                    </Button>
                </Grid>
            </TabItem>
            <!--<TabItem Width="100" Height="30">
                <TabItem.Header>
                    <TextBlock>
                                      <TextBlock.ToolTip>
                                        <ToolTip>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold">Test output</TextBlock>
                                                <TextBlock>Live output from test</TextBlock>
                                            </StackPanel>
                                        </ToolTip>
                                    </TextBlock.ToolTip>     
                        Test output
                    </TextBlock>
                </TabItem.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="29*"/>
                        <ColumnDefinition Width="91*"/>
                    </Grid.ColumnDefinitions>
                    <TabControl HorizontalAlignment="Left" Height="475" Margin="10,34,0,0" VerticalAlignment="Top" Width="580" Grid.ColumnSpan="2" TabStripPlacement="Right">
                        <TabItem Header="Server resources">
                            <Grid Background="#FFE5E5E5"/>
                        </TabItem>
                        <TabItem Header="Trace">
                            <Grid Background="#FFE5E5E5"/>
                        </TabItem>
                    </TabControl>

                </Grid>
            </TabItem>-->
        </TabControl>
    </Grid>
</Window>
